#!/usr/bin/env python


from waflib import Logs


def options(opt):
	opt.add_option('--disable-vpu', action = 'store_true', default = False, help = 'disable VPU plugin [default: enabled]')


def configure(conf):
	if conf.options.disable_vpu:
		return

	if not conf.env['WITH_GSTVIDEO']:
		return

	if conf.check_cfg(package = 'libimxvpuapi >= 0.10.3', uselib_store = 'IMXVPUAPI', args = '--cflags --libs', mandatory = 0):
		Logs.pprint('GREEN', 'found installed imxvpuapi library - VPU elements will be built')
		conf.env['BUILD_VPU_ELEMENTS'] = 1
	else:
		Logs.pprint('YELLOW', 'could not find installed imxvpuapi library - VPU elements will not be built')


def build(bld):
	if bld.env['BUILD_VPU_ELEMENTS']:
		bld(
			features = ['c', bld.env['CLIBTYPE']],
			includes = ['.', '../..'],
			uselib = bld.env['COMMON_USELIB'] + ['IMXVPUAPI'],
			use = 'gstimxcommon',
			target = 'gstimxvpu',
			source = bld.path.ant_glob('*.c'),
			install_path = bld.env['PLUGIN_INSTALL_PATH']
		)

